package com.fw.ui.view.settings.usercontrol.bouser.event;

import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.fw.ui.ApplicationUI;
import com.fw.ui.bao.PropertyBAO;
import com.fw.ui.util.VaadinApplicationObjectSupport;
import com.fw.ui.view.event.AbstractButtonClickListener;
import com.fw.ui.view.settings.usercontrol.bouser.ViewBOUserView;
import com.vaadin.navigator.Navigator;
import com.vaadin.ui.Button.ClickEvent;

@Component
@Scope(SCOPE_PROTOTYPE)
public class ViewBOUserCloseButtonClickListener extends AbstractButtonClickListener {

    private static final long serialVersionUID = 1L;

    @Autowired
    protected transient VaadinApplicationObjectSupport app;
    @Autowired
    private PropertyBAO propertyBAO;

    @Override
    public Map<String, Object> click(ClickEvent event) {
	ViewBOUserView viewBOUserView = (ViewBOUserView) this.getBasedComponent();
	Navigator navigator = ((ApplicationUI) viewBOUserView.getUI()).getNavigator();
	String landing = propertyBAO.getPropertyValue("view.settings-user-control-bouser-search.path");
	navigator.navigateTo(landing);
	return null;
    }

    @Override
    public boolean validate(ClickEvent event) {
	return true;
    }

}
